package com.lq.ecoldchain.ui.mine.carInfo

import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.lq.ecoldchain.R
import com.lq.ecoldchain.base.BaseNavigator
import com.lq.ecoldchain.base.view.BaseActivity
import com.lq.ecoldchain.databinding.ActivityCarInfoBinding
import com.lq.ecoldchain.entity.CarType
import org.kodein.di.Kodein
import org.kodein.di.generic.instance

/*
*2018/12/28 0028  13:10
*货车信息 by lq
*/
@Route(path = BaseNavigator.carInfo)
class CarInfoActivity:BaseActivity<ActivityCarInfoBinding>(){
    override val kodein =Kodein.lazy {
        extend(parentKodein)
        import(carKodeinModule)
    }

    override val layoutId = R.layout.activity_car_info
    override val viewDelegate: CarInfoDelegate by instance()

    override fun initView() {
        binding.delegate = viewDelegate
        titleText("货车信息")
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
       if(resultCode==RESULT_OK && requestCode==viewDelegate.viewModel.carTypeRequestCode){
           val entity = data?.getParcelableExtra<CarType>("data")
           if(entity!=null){
               viewDelegate.viewModel.maxTon.value = entity.tonnage
               viewDelegate.viewModel.maxCube.value = entity.cube
               viewDelegate.viewModel.carType.value = entity.id.toString()
           }
       }
    }

}